package com.pinkpig.excel.row;


import com.pinkpig.excel.metadata.DoubleTableMetaData;
import com.pinkpig.excel.row.model.RowModel;
import com.pinkpig.excel.row.model.TableRowModel;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fengs
 */
public class TableRowModelBuilder implements RowModelBuilder<DoubleTableMetaData> {

    @Override
    public List<RowModel> build(DoubleTableMetaData tableMetaData){
        List<RowModel> rows = new ArrayList<>();
        TableRowModel tableRowModel = new TableRowModel();
        tableRowModel.setTableName(tableMetaData.getTableMetaData1().getTableName());
        tableRowModel.setTableNameCh(tableMetaData.getTableMetaData1().getRemarks());
        if(null!=tableMetaData.getTableMetaData2()){
            tableRowModel.setTableName2(tableMetaData.getTableMetaData2().getTableName());
            tableRowModel.setTableNameCh2(tableMetaData.getTableMetaData2().getRemarks());
        }
        tableRowModel.setCategory(tableMetaData.getTableMetaData1().getCategory());
        rows.add(tableRowModel);
        return rows;
    }

}
